package org.anupta.game.server.inter.packet.connect;

import org.anupta.game.server.inter.client.InterClient;
import org.anupta.game.server.inter.packet.InterPacket;
import org.anupta.game.server.inter.packet.InterPacketID;
import org.anupta.game.utils.others.Config;
import org.apache.mina.core.buffer.IoBuffer;

public class Connect extends InterPacket {
	public Connect(InterClient client) {
		super(client);
		pack(packetOut);
		doPacket(packetOut);
	}

	@Override
	public void unpack(IoBuffer buffer) {
	}

	@Override
	public void pack(IoBuffer buffer) {
		buffer.put(InterPacketID.CONNECT.getId());
		buffer.put(Config.ID);
		buffer.put(Config.TYPE.getType());
		buffer.put(Config.STATE.getState());
		buffer.put(Config.POPULATION.getPopulation());
		writeString(Config.GAME_IP);
		buffer.putInt(Config.GAME_PORT);
	}

	@Override
	public void doPacket(IoBuffer buffer) {
		client.send(this);
	}
}
